Public Class Index
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not Page.IsPostBack Then
            Session("StatusHide") = "0"
        End If
   End Sub

    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Dim TargetURL As String = Server.MapPath("..\") & "UserManual\" & Session("UserManualFile")
        Dim FileNameCSV As String = TargetURL
        DisplayDownloadDialog(FileNameCSV)
    End Sub
    Sub DisplayDownloadDialog(ByVal PathVirtual As String)
        Dim strPhysicalPath
        Dim objFileInfo As System.IO.FileInfo
        Dim strFileName As String = PathVirtual
        Try
            strPhysicalPath = strFileName 'Server.MapPath(FileNameCSV)
            'exit if file does not exist
            If Not System.IO.File.Exists(strPhysicalPath) Then Exit Sub
            objFileInfo = New System.IO.FileInfo(strPhysicalPath)
            Response.Clear()
            'Add Headers to enable dialog display
            Response.AddHeader("Content-Disposition", "attachment; filename=" & _
                objFileInfo.Name)
            Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
            Response.ContentType = "application/octet-stream"
            Response.WriteFile(objFileInfo.FullName)
        Catch
        Finally
            Response.End()
        End Try
    End Sub
End Class
